﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccessLayer;
using MyCommon;

namespace BussinessLayer
{
    public class ThietBiKhoBO : BaseBO
    {
        #region Singleton implemented
        private static ThietBiKhoBO _instance;
        private ThietBiKhoBO()
        { }
        public static ThietBiKhoBO getInstance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new ThietBiKhoBO();
                }
                return _instance;
            }
        }
        #endregion

        public IEnumerable<ThietBiKho> GetAllThietBiKho()
        {
            return _dao.ThietBiKho.GetAllThietBiKho();
        }
        public ThietBiKho GetThietBiKhoById(int id)
        {
            return _dao.ThietBiKho.GetThietBiKhoById(id);
        }
        public bool UpdateThietBiKho(ThietBiKho inThietBiKho)
        {
            return _dao.ThietBiKho.UpdateThietBiKho(inThietBiKho);
        }
        public bool InsertThietBiKho(ThietBiKho inThietBiKho)
        {
            return _dao.ThietBiKho.InsertThietBiKho(inThietBiKho);
        }
        public ReturnValue<bool> DelThietBiKho(int id)
        {
            return _dao.ThietBiKho.DelThietBiKho(id);
        }
        public string GenerateMaThietBiKho()
        {
            ThietBiKho aObj = _dao.ThietBiKho.GetLastRecord();
            if (aObj != null)
            {
                return Utils.GenerateCode(CodeType.ThietBiKho, aObj.Id + 1);
            }
            else
            {
                return Utils.GenerateCode(CodeType.ThietBiKho, 1);
            }

        }

    }
}
